#define _GNU_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

void* first_thread(void* argv){
    printf("线程1%d开始执行，准备休息1秒\n",gettid());
    sleep(1);
    printf("线程1%d醒来了",gettid());
}

void* second_thread(void* argv){
    printf("线程2%d开始执行，准备休息1秒\n",gettid());
    
}

int main(){
    printf("主线程开始执行%d，准备创建线程\n",gettid());
    pthread_t tid1,tid2;
    pthread_create(&tid1,NULL,first_thread,NULL);
    pthread_create(&tid2,NULL,second_thread,NULL);
    printf("main thread,thread1%ld,thread2%ld\n",tid1,tid2);
    pthread_join(tid1,NULL);
    pthread_join(tid2,NULL);
    printf("main thread end\n");
    return 0;
}

